﻿CREATE VIEW reports.v_BorrowerHistory
AS
SELECT     dbo.t_Loan_Borrower.LoanID, dbo.t_Borrower.FirstName, dbo.t_Borrower.LastName, dbo.t_Borrower.SSN, dbo.t_Borrower.PhoneHome, 
                      dbo.t_Borrower.PhoneCell, dbo.t_Borrower.FullName, dbo.t_Address.Street, dbo.t_Address.CityName, dbo.t_Address.Zip, dbo.t_Address.StateCode, 
                      dbo.t_CarInfo.VIN, dbo.thist_Borrower.Hist_DateStamp AS B_DateStamp, dbo.thist_Borrower.Hist_UserName AS B_UserNane, 
                      dbo.thist_CarInfo.Hist_DateStamp AS C_DateStamp, dbo.thist_CarInfo.Hist_UserName AS C_UserName, 
                      dbo.thist_Address.Hist_DateStamp AS A_DateStamp, dbo.thist_Address.Hist_UserName AS A_UserName
FROM         dbo.t_Borrower INNER JOIN
                      dbo.t_Loan_Borrower ON dbo.t_Borrower.ID = dbo.t_Loan_Borrower.BorrowerID AND dbo.t_Borrower.ID = dbo.t_Loan_Borrower.BorrowerID INNER JOIN
                      dbo.t_Address ON dbo.t_Borrower.ID = dbo.t_Address.BorrowerID INNER JOIN
                      dbo.thist_Address ON dbo.t_Address.ID = dbo.thist_Address.AddressID INNER JOIN
                      dbo.thist_Borrower ON dbo.t_Loan_Borrower.BorrowerID = dbo.thist_Borrower.BorrowerID INNER JOIN
                      dbo.t_CarInfo ON dbo.t_Loan_Borrower.LoanID = dbo.t_CarInfo.LoanID INNER JOIN
                      dbo.thist_CarInfo ON dbo.t_Loan_Borrower.LoanID = dbo.thist_CarInfo.LoanID
WHERE     (dbo.t_Address.Pos = 0) AND (dbo.t_Loan_Borrower.Pos = 0)

GO
EXECUTE sp_addextendedproperty @name = N'MS_DiagramPane1', @value = N'[0E232FF0-B466-11cf-A24F-00AA00A3EFFF, 1.00]
Begin DesignProperties = 
   Begin PaneConfigurations = 
      Begin PaneConfiguration = 0
         NumPanes = 4
         Configuration = "(H (1[32] 4[28] 2[20] 3) )"
      End
      Begin PaneConfiguration = 1
         NumPanes = 3
         Configuration = "(H (1 [50] 4 [25] 3))"
      End
      Begin PaneConfiguration = 2
         NumPanes = 3
         Configuration = "(H (1 [50] 2 [25] 3))"
      End
      Begin PaneConfiguration = 3
         NumPanes = 3
         Configuration = "(H (4 [30] 2 [40] 3))"
      End
      Begin PaneConfiguration = 4
         NumPanes = 2
         Configuration = "(H (1 [56] 3))"
      End
      Begin PaneConfiguration = 5
         NumPanes = 2
         Configuration = "(H (2 [66] 3))"
      End
      Begin PaneConfiguration = 6
         NumPanes = 2
         Configuration = "(H (4 [50] 3))"
      End
      Begin PaneConfiguration = 7
         NumPanes = 1
         Configuration = "(V (3))"
      End
      Begin PaneConfiguration = 8
         NumPanes = 3
         Configuration = "(H (1[56] 4[18] 2) )"
      End
      Begin PaneConfiguration = 9
         NumPanes = 2
         Configuration = "(H (1 [75] 4))"
      End
      Begin PaneConfiguration = 10
         NumPanes = 2
         Configuration = "(H (1[66] 2) )"
      End
      Begin PaneConfiguration = 11
         NumPanes = 2
         Configuration = "(H (4 [60] 2))"
      End
      Begin PaneConfiguration = 12
         NumPanes = 1
         Configuration = "(H (1) )"
      End
      Begin PaneConfiguration = 13
         NumPanes = 1
         Configuration = "(V (4))"
      End
      Begin PaneConfiguration = 14
         NumPanes = 1
         Configuration = "(V (2))"
      End
      ActivePaneConfig = 0
   End
   Begin DiagramPane = 
      Begin Origin = 
         Top = 0
         Left = 0
      End
      Begin Tables = 
         Begin Table = "thist_Borrower"
            Begin Extent = 
               Top = 470
               Left = 610
               Bottom = 578
               Right = 767
            End
            DisplayFlags = 280
            TopColumn = 0
         End
         Begin Table = "t_Loan_Borrower"
            Begin Extent = 
               Top = 346
               Left = 399
               Bottom = 454
               Right = 550
            End
            DisplayFlags = 280
            TopColumn = 0
         End
         Begin Table = "t_Borrower"
            Begin Extent = 
               Top = 155
               Left = 255
               Bottom = 318
               Right = 477
            End
            DisplayFlags = 280
            TopColumn = 23
         End
         Begin Table = "t_Address"
            Begin Extent = 
               Top = 146
               Left = 53
               Bottom = 311
               Right = 219
            End
            DisplayFlags = 280
            TopColumn = 1
         End
         Begin Table = "thist_Address"
            Begin Extent = 
               Top = 25
               Left = 225
               Bottom = 133
               Right = 382
            End
            DisplayFlags = 280
            TopColumn = 0
         End
         Begin Table = "t_CarInfo"
            Begin Extent = 
               Top = 215
               Left = 679
               Bottom = 323
               Right = 880
            End
            DisplayFlags = 280
            TopColumn = 0
         End
         Begin Table = "thist_CarInfo"
            Begin Extent = 
               Top = 77
               Left = 642
               Bottom = 185
               Right = 799', @level0type = N'SCHEMA', @level0name = N'reports', @level1type = N'VIEW', @level1name = N'v_BorrowerHistory';


GO
EXECUTE sp_addextendedproperty @name = N'MS_DiagramPane2', @value = N'End
            DisplayFlags = 280
            TopColumn = 0
         End
      End
   End
   Begin SQLPane = 
   End
   Begin DataPane = 
      Begin ParameterDefaults = ""
      End
      Begin ColumnWidths = 10
         Width = 284
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
      End
   End
   Begin CriteriaPane = 
      Begin ColumnWidths = 11
         Column = 1440
         Alias = 1200
         Table = 1170
         Output = 720
         Append = 1400
         NewValue = 1170
         SortType = 1350
         SortOrder = 1410
         GroupBy = 1350
         Filter = 1350
         Or = 1350
         Or = 1350
         Or = 1350
      End
   End
End', @level0type = N'SCHEMA', @level0name = N'reports', @level1type = N'VIEW', @level1name = N'v_BorrowerHistory';


GO
EXECUTE sp_addextendedproperty @name = N'MS_DiagramPaneCount', @value = 2, @level0type = N'SCHEMA', @level0name = N'reports', @level1type = N'VIEW', @level1name = N'v_BorrowerHistory';

